package durak.common.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class CardsOnTheTable implements Serializable {

	List<Card> attackCards;
	List<Card> defendCards;

	public CardsOnTheTable() {
		attackCards = new ArrayList<Card>();
		defendCards = new ArrayList<Card>();
	}

	public Cards getCards() {
		Cards allCards = new Cards();
		allCards.addCards(new Cards(attackCards));
		allCards.addCards(new Cards(defendCards));
		return allCards;
	}

	public Cards retrieveCards() {
		Cards cards = new Cards();
		cards.addCards(getCards());
		attackCards.clear();
		defendCards.clear();
		return cards;
	}

	public boolean isEmpty() {
		return attackCards.isEmpty() && defendCards.isEmpty();
	}

	public void addAttackCards(Cards cards) {
		attackCards.addAll(cards.getCards());
	}

	public void addAttackCard(Card card) {
		attackCards.add(card);
	}
	
	public void addDefendCards(Cards cards) {
		defendCards.addAll(cards.getCards());
	}
	
	public void addDefendCard(Card card, int index) {
		defendCards.add(card);
	}
	
	public List<Card> getAttackCards() {
		return attackCards;
	}

	public Cards getDefendCards() {
		return new Cards(defendCards);
	}
}
